#include <iostream>
#include <RevEng/RevEng.hpp>

using namespace RevEng;

class Process : public RevEng::IThreaded
{
private:
	Mutex Console;

public:
	Process(const Mutex& ConsoleMutex) : Console(ConsoleMutex)
	{
	}

	virtual RevEng::Int32 Run(void* Param)
	{
		Console.Lock();
		std::cout << "[Thread] Leseando aqui pues oie!!" << std::endl;
		std::cout << "[Thread] Escribe lo que quieras y presiona [Enter]" << std::endl;
		Console.Unlock();

		std::cin.get();
		
		return 0;
	}
};


int main( )
{
	Thread MyThread;
	Mutex ConsoleGuard;
	Process MyProcess(ConsoleGuard);
	
	MyThread.SetThreaded( &MyProcess );
	MyThread.Start(NULL);
	
	ConsoleGuard.Lock();
	std::cout << "Contando de 0 a mil millones..." << std::endl;
	ConsoleGuard.Unlock();
	
	for(RevEng::UInt32 i=0; i<1000000000; ++i)
	{
		if (i%100000000 == 0)
		{
			ConsoleGuard.Lock();
			std::cout << "LLevamos cien millones mas!!" << std::endl;
			ConsoleGuard.Unlock();
		}
	}

	//Esperamos a que el hilo termine.
	MyThread.Wait();

	return 0;
}
